<template>
  <div id="d">
    <el-row>
      <el-col :span="22">
        <h4 style="margin-left: 20px; margin-top: 20px">定制方案</h4>
      </el-col>
      <el-col :span="2">
        <el-button
          style="margin-left: 20px; margin-top: 20px"
          type="primary"
          plain
          @click="fh()"
          >返回</el-button
        >
      </el-col>
    </el-row>
    <hr />
    <el-row>
      <el-col :span="11">
        <div
          style="
            box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
            width: 100%;
            height: 90%;
            margin-left: 40px;
            margin-top: 20px;
          "
        >
          <el-tabs
            v-model="addmenu"
            type="border-card"
            style="margin-top: -20px; height: 600px"
          >
            <el-tab-pane name="1" label="基本信息">
              <div style="margin-left: 10px; margin-top: 20px">
                <el-row>
                  <el-col :span="3" style="text-align: auto">档案号:</el-col>
                  <el-col :span="3">{{ member.filenumber }}</el-col>
                  <el-col :span="6" style="text-align: auto">.</el-col>

                  <el-col :span="3" style="text-align: auto">姓名:</el-col>
                  <el-col :span="3">{{ member.name }}</el-col>
                  <el-col :span="6" style="text-align: auto">.</el-col>
                </el-row>
                <br />
                <el-row>
                  <el-col :span="3" style="text-align: auto">性别:</el-col>
                  <el-col :span="3">
                    {{ member.sex == 1 ? "男" : member.sex == 2 ? "女" : "" }}
                  </el-col>
                  <el-col :span="6" style="text-align: auto">.</el-col>

                  <el-col :span="3" style="text-align: auto">年龄:</el-col>
                  <el-col :span="3">
                    {{ member.age }}
                  </el-col>
                  <el-col :span="6" style="text-align: auto">.</el-col>
                </el-row>
                <hr />
                <el-row style="margin-top: 20px">
                  <el-col :span="2" style="text-align: auto">疾病史:</el-col>
                  <el-col
                    :span="22"
                    style="
                      text-align: left;
                      height: 90px;
                      width: 90%;
                      box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
                    "
                  >
                    {{ Membermedicalhistory.medicalhistory }}</el-col
                  >
                </el-row>

                <el-row style="margin-top: 20px">
                  <el-col :span="2" style="text-align: auto">遗传史:</el-col>
                  <el-col
                    :span="22"
                    style="
                      text-align: left;
                      height: 90px;
                      width: 90%;
                      box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
                    "
                    >{{ Membermedicalhistory.familyhistory }}</el-col
                  >
                </el-row>

                <el-row style="margin-top: 20px">
                  <el-col :span="2" style="text-align: auto">手术史:</el-col>
                  <el-col
                    :span="22"
                    style="
                      text-align: left;
                      height: 90px;
                      width: 90%;
                      box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
                    "
                    >{{ Membermedicalhistory.previoushistory }}</el-col
                  >
                </el-row>
              </div>
              <br />
            </el-tab-pane>

            <el-tab-pane name="2" label="体检信息" style="height: 600px">
              <div style="margin-left: 10px; margin-top: 20px">
                <el-table :data="listcha" stripe style="width: 100%">
                  <el-table-column
                    prop="member.filenumber"
                    label="档案号"
                    width="180"
                  >
                  </el-table-column>
                  <el-table-column prop="examDate" label="体检日期" width="180">
                  </el-table-column>
                  <el-table-column prop="setmeal.name" label="体检套餐">
                  </el-table-column>
                  <el-table-column label="查看体检报告">
                    <template slot-scope="scope">
                      <el-popover placement="right" trigger="click">
                        <div
                          class="demo-image__preview"
                          style="
                            margin-left: 20px;
                            margin-top: 20px;
                            width: 700px;
                            height: 800px;
                          "
                        >
                          <el-image
                            style="width: 100%; height: 100%"
                            :src="require('@/image/' + scope.row.order.img)"
                          >
                          </el-image>
                        </div>
                        <el-link
                          slot="reference"
                          @click="loadcha(scope.$index, scope.row)"
                          type="success"
                          >查看</el-link
                        >
                      </el-popover>
                    </template>
                  </el-table-column>
                </el-table>
              </div>
              <br />
            </el-tab-pane>

            <el-tab-pane name="3" label="评估结果" style="height: 600px">
              <div style="margin-left: 10px; margin-top: 20px">
                <h6>体质评估</h6>
                <hr />
                <el-table :data="BodytypeCha" stripe style="width: 100%">
                  <el-table-column prop="" label="档案号" width="200">
                    {{ member.filenumber }}
                  </el-table-column>
                  <el-table-column prop="" label="姓名">
                    {{ member.name }}
                  </el-table-column>
                  <el-table-column
                    prop="createtime"
                    label="评估日期"
                    width="200"
                  >
                  </el-table-column>
                  <el-table-column label="查看评估报告">
                    <template slot-scope="scope">
                      <el-popover placement="right" width="300" trigger="click">
                        <div style="margin-left: 20px; margin-top: 20px">
                          <el-row>
                            <el-col :span="12">阳虚体质 :</el-col>
                            <el-col :span="12">
                              {{
                                scope.row.yangquality == 0 ? "否" : "是"
                              }}</el-col
                            >
                          </el-row>
                          <hr />
                          <el-row>
                            <el-col :span="12">阴虚体质 :</el-col>
                            <el-col :span="12">
                              {{
                                scope.row.yindeficiency == 0 ? "否" : "是"
                              }}</el-col
                            >
                          </el-row>
                          <hr />
                          <el-row>
                            <el-col :span="12">气虚体质 :</el-col>
                            <el-col :span="12">
                              {{
                                scope.row.yangquality == 0 ? "否" : "是"
                              }}</el-col
                            >
                          </el-row>
                          <hr />
                        </div>
                        <el-link
                          slot="reference"
                          @click="loadpg(scope.$index, scope.row)"
                          type="success"
                          >查看</el-link
                        >
                      </el-popover>
                    </template>
                  </el-table-column>
                </el-table>
              </div>

              <div style="margin-left: 10px; margin-top: 20px">
                <h6>心理评估</h6>
                <hr />
                <el-table :data="MentalityresultCha" stripe style="width: 100%">
                  <el-table-column prop="" label="档案号">
                    {{ member.filenumber }}
                  </el-table-column>
                  <el-table-column prop="" label="姓名">
                    {{ member.name }}
                  </el-table-column>
                  <el-table-column
                    prop="createtime"
                    label="评估日期"
                    width="200"
                  >
                  </el-table-column>
                  <el-table-column label="查看评估报告">
                    <template slot-scope="scope">
                      <el-popover placement="right" width="300" trigger="click">
                        <div style="margin-left: 20px; margin-top: 20px">
                          <el-row>
                            <el-col :span="12">强迫症 :</el-col>
                            <el-col :span="12">
                              {{ scope.row.ocd == 0 ? "否" : "是" }}</el-col
                            >
                          </el-row>
                          <hr />
                          <el-row>
                            <el-col :span="12">焦虑症 :</el-col>
                            <el-col :span="12">
                              {{ scope.row.anxiety == 0 ? "否" : "是" }}</el-col
                            >
                          </el-row>
                          <hr />
                          <el-row>
                            <el-col :span="12">恐怖化 :</el-col>
                            <el-col :span="12">
                              {{ scope.row.terror == 0 ? "否" : "是" }}</el-col
                            >
                          </el-row>
                          <hr />
                        </div>
                        <el-link
                          slot="reference"
                          @click="loadpg(scope.$index, scope.row)"
                          type="success"
                          >查看</el-link
                        >
                      </el-popover>
                    </template>
                  </el-table-column>
                </el-table>
              </div>
              <br />
            </el-tab-pane>
          </el-tabs>
        </div>
      </el-col>
      <el-col :span="2">.</el-col>
      <el-col :span="11">
        <div
          style="
            box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
            width: 100%;
            height: 90%;
            margin-left: -40px;
            margin-top: 20px;
          "
        >
          <el-tabs
            v-model="upmenu"
            type="border-card"
            style="margin-top: -20px; height: 600px"
          >
            <el-tab-pane name="1" label="基本信息">
              <div style="margin-left: 10px; margin-top: 20px">
                <el-row>
                  <el-col :span="3" style="text-align: auto">档案号:</el-col>
                  <el-col :span="3">{{ member.filenumber }}</el-col>
                  <el-col :span="6" style="text-align: auto">.</el-col>

                  <el-col :span="3" style="text-align: auto">姓名:</el-col>
                  <el-col :span="3">{{ member.name }}</el-col>
                  <el-col :span="6" style="text-align: auto">.</el-col>
                </el-row>
                <br />
                <el-row>
                  <el-col :span="3" style="text-align: auto">性别:</el-col>
                  <el-col :span="3">
                    {{ member.sex == 1 ? "男" : member.sex == 2 ? "女" : "" }}
                  </el-col>
                  <el-col :span="6" style="text-align: auto">.</el-col>

                  <el-col :span="3" style="text-align: auto">年龄:</el-col>
                  <el-col :span="3">
                    {{ member.age }}
                  </el-col>
                  <el-col :span="6" style="text-align: auto">.</el-col>
                </el-row>
                <hr />
                <el-row>
                  <el-col :span="3" style="text-align: auto">方案标题:</el-col>
                  <el-col :span="5">
                    <el-input
                      type="text"
                      v-model="upform.scheme.schemetittle"
                      size="small"
                      style="margin-top: -10px"
                  /></el-col>
                  <el-col :span="3" style="text-align: auto">.</el-col>

                  <el-col :span="3" style="text-align: auto"
                    >* 选用模版:</el-col
                  >
                  <el-col :span="5">
                    <el-popover placement="right" width="500" trigger="click">
                      <el-table :data="Schemelist">
                        <el-table-column
                          width="150"
                          property="schemetittle"
                          label="方案标题"
                        ></el-table-column>
                        <el-table-column
                          property="schemetarget"
                          width="250"
                          label="方案目标"
                        ></el-table-column>
                        <el-table-column label="操作" width="50">
                          <template slot-scope="scope">
                            <el-button
                              type="success"
                              icon="el-icon-check"
                              circle
                              @click="jia(scope.$index, scope.row)"
                              size="mini"
                            ></el-button>
                          </template>
                        </el-table-column>
                      </el-table>
                      <el-select
                        @change="changes(upform.scheme.modelid)"
                        v-model="upform.scheme.modelid"
                        slot="reference"
                        size="small"
                        style="margin-top: -10px"
                        placeholder="请选择"
                      >
                        <el-option
                          v-for="item in models"
                          :key="item"
                          :label="item"
                          :value="item"
                        >
                        </el-option>
                      </el-select>
                    </el-popover>
                  </el-col>
                  <el-col :span="5" style="text-align: auto">.</el-col>
                </el-row>

                <br />
                <el-row>
                  <el-col :span="3" style="text-align: auto">开始时间:</el-col>
                  <el-col :span="5">
                    <el-date-picker
                      type="date"
                      v-model="upform.scheme.starttime"
                      size="small"
                      style="margin-top: -10px"
                      placeholder="开始时间"
                    >
                    </el-date-picker
                  ></el-col>
                  <el-col :span="3" style="text-align: auto">.</el-col>

                  <el-col :span="3" style="text-align: auto">结束时间:</el-col>
                  <el-col :span="5">
                    <el-date-picker
                      type="date"
                      v-model="upform.scheme.endtime"
                      size="small"
                      style="margin-top: -10px"
                      placeholder="结束时间"
                    >
                    </el-date-picker
                  ></el-col>
                  <el-col :span="5" style="text-align: auto">.</el-col>
                </el-row>

                <br />
                <el-row>
                  <el-col :span="3" style="text-align: auto">方案目标:</el-col>
                  <el-col :span="18">
                    <el-input
                      type="textarea"
                      v-model="upform.scheme.schemetarget"
                      size="small"
                  /></el-col>
                  <el-col :span="3" style="text-align: auto">.</el-col>
                </el-row>
                <br />
                <el-row>
                  <hr />
                  <el-col :span="4" style="text-align: auto"
                    ><strong>健康管理师:</strong></el-col
                  >
                  <el-col :span="14" style="text-align: left">
                    <el-select disabled v-model="healthmgrid" clearable>
                      <el-option
                        :label="$store.state.Member.user.fullname"
                        :value="$store.state.Member.user.id"
                      >
                      </el-option>
                    </el-select>
                  </el-col>
                  <el-col :span="6">.</el-col>
                </el-row>
              </div>
            </el-tab-pane>

            <el-tab-pane name="2" label="饮食干预">
              <el-row style="text-align: right">
                <el-col>
                  <el-popover placement="right" width="400" trigger="click">
                    <el-row>
                      <el-col :span="12">
                        <el-input
                          v-model="meals.name"
                          size="small "
                          placeholder="食物名称"
                        ></el-input>
                      </el-col>
                      <el-col :span="12">
                        <el-button
                          style="margin-left: 10px"
                          type="success"
                          size="small "
                          @click="mpage()"
                        >
                          查询</el-button
                        >
                      </el-col>
                    </el-row>
                    <el-table :data="meals.list">
                      <el-table-column
                        width="150"
                        property="name"
                        label="食品名称"
                      ></el-table-column>
                      <el-table-column
                        width="100"
                        property="typeid"
                        label="所属类别"
                      ></el-table-column>
                      <el-table-column width="100" label="操作">
                        <template slot-scope="scope">
                          <el-button
                            type="success"
                            @click="upjia(scope.$index, scope.row)"
                            size="mini"
                            >+</el-button
                          >
                        </template>
                      </el-table-column>
                    </el-table>
                    <el-pagination
                      @size-change="mhandleSizeChange"
                      @current-change="mhandleCurrentChange"
                      :current-page="meals.num"
                      :page-sizes="[10, 20, 50, 100]"
                      :page-size="meals.size"
                      layout="total, sizes, prev, pager, next, jumper"
                      :total="meals.total"
                    >
                    </el-pagination>

                    <el-button
                      type="primary"
                      @click="mpage()"
                      plain
                      slot="reference"
                      >添加食物</el-button
                    >
                  </el-popover>
                </el-col>
              </el-row>

              <hr />
              <el-table :data="upform.scheme.foods" style="width: 100%">
                <el-table-column prop="eattimes" label="" width="100">
                  <template slot-scope="scope">
                    <el-button
                      size="mini"
                      type="danger"
                      style="width: 20px"
                      @click="upjian(scope.$index, scope.row)"
                      >-
                    </el-button>
                  </template>
                </el-table-column>
                <el-table-column prop="recommendfood" label="食物名称">
                </el-table-column>
                <el-table-column prop="foodquantity" label="份量/餐">
                  <template slot-scope="scope">
                    <el-button
                      size="mini"
                      @click="fjianUP(scope.$index, scope.row)"
                      >-</el-button
                    >
                    <el-button size="mini" style="border: none"
                      ><strong>{{ scope.row.foodquantity }}</strong>
                    </el-button>
                    <el-button
                      size="mini"
                      @click="fjiaUP(scope.$index, scope.row)"
                      >+</el-button
                    >
                  </template>
                </el-table-column>
                <el-table-column prop="eattimes" label="餐数/天">
                  <template slot-scope="scope">
                    <el-button
                      size="mini"
                      @click="cjianUP(scope.$index, scope.row)"
                      >-</el-button
                    >
                    <el-button size="mini" style="border: none"
                      ><strong>{{ scope.row.eattimes }}</strong>
                    </el-button>
                    <el-button
                      size="mini"
                      @click="cjiaUP(scope.$index, scope.row)"
                      >+</el-button
                    >
                  </template>
                </el-table-column>
              </el-table>
            </el-tab-pane>

            <el-tab-pane name="3" label="运动干预">
              <el-row style="text-align: right">
                <el-col>
                  <el-popover placement="right" width="400" trigger="click">
                    <el-row>
                      <el-col :span="12">
                        <el-input
                          v-model="sportsItemLibrary.name"
                          size="small "
                          placeholder="运动名称"
                        ></el-input>
                      </el-col>
                      <el-col :span="12">
                        <el-button
                          style="margin-left: 10px"
                          type="success"
                          size="small "
                          @click="spage()"
                        >
                          查询</el-button
                        >
                      </el-col>
                    </el-row>
                    <el-table :data="sportsItemLibrary.list">
                      <el-table-column
                        property="name"
                        label="项目名称"
                      ></el-table-column>
                      <el-table-column
                        property="strength"
                        label="项目强度"
                      ></el-table-column>
                      <el-table-column label="适用性别">
                        <template slot-scope="scope">
                          {{
                            scope.row.applytogender == 0
                              ? "男"
                              : scope.row.applytogender == 1
                              ? "女"
                              : "不限"
                          }}
                        </template>
                      </el-table-column>
                      <el-table-column label="操作">
                        <template slot-scope="scope">
                          <el-button
                            type="success"
                            @click="upjias(scope.$index, scope.row)"
                            size="mini"
                            >+</el-button
                          >
                        </template>
                      </el-table-column>
                    </el-table>
                    <el-pagination
                      @size-change="shandleSizeChange"
                      @current-change="shandleCurrentChange"
                      :current-page="sportsItemLibrary.num"
                      :page-sizes="[10, 20, 50, 100]"
                      :page-size="sportsItemLibrary.size"
                      layout="total, sizes, prev, pager, next, jumper"
                      :total="sportsItemLibrary.total"
                    >
                    </el-pagination>

                    <el-button
                      type="primary"
                      @click="spage()"
                      plain
                      slot="reference"
                      >添加项目</el-button
                    >
                  </el-popover>
                </el-col>
              </el-row>

              <hr />
              <el-table :data="upform.scheme.sprots" style="width: 100%">
                <el-table-column prop="eattimes" label="" width="100">
                  <template slot-scope="scope">
                    <el-button
                      size="mini"
                      type="danger"
                      style="width: 20px"
                      @click="upjians(scope.$index, scope.row)"
                      >-
                    </el-button>
                  </template>
                </el-table-column>
                <el-table-column prop="sportname" label="项目名称">
                </el-table-column>
                <el-table-column prop="sporttime" label="运动时长（分钟）">
                  <template slot-scope="scope">
                    <el-row>
                      <el-col :span="10"
                        ><el-input size="mini" v-model="scope.row.sporttime"
                      /></el-col>
                      <el-col :span="14">/分钟</el-col>
                    </el-row>
                  </template>
                </el-table-column>
                <el-table-column prop="sportcycle" label="运动周期">
                  <template slot-scope="scope">
                    <el-input
                      size="mini"
                      v-model="scope.row.sportcycle"
                      style="width: 50%"
                    />
                  </template>
                </el-table-column>
              </el-table>
            </el-tab-pane>
          </el-tabs></div
      ></el-col>
    </el-row>
    <hr />
    <el-row>
      <el-col :span="20">.</el-col>
      <el-col :span="2" style="margin-left: -20px"
        ><el-button type="primary" @click="add()" style="width: 90%"
          >保存</el-button
        ></el-col
      >
      <el-col :span="2"
        ><el-button type="primary" plain @click="cz()" style="width: 90%"
          >重置</el-button
        ></el-col
      >
    </el-row>
  </div>
</template>

<script>
export default {
  data() {
    return {
      addmenu: "1",
      upmenu: "1",
      upform: {
        scheme: {
          // 基础数据
          schemetittle: "",
          modelid: "",
          starttime: "",
          endtime: "",
          schemetarget: "",
          foods: [],
          sprots: [],
        },
      },
      healthmgrid: this.$store.state.Member.user.id,
      Schemelist: [],
      models: [
        // 选用模版
        "阳虚",
        "阴虚",
        "气虚",
        "强迫症",
        "焦虑症",
        "恐怖化",
        "糖尿病",
        "哮喘",
        "肥胖症",
        "老年高血压",
        "高血压",
        "高血糖",
      ],
      // 饮食查询
      meals: {
        num: 1,
        size: 10,
        total: 2,
        list: [],
        name: "",
      },
      // 运动查询
      sportsItemLibrary: {
        num: 1,
        size: 10,
        total: 2,
        list: [],
        name: "",
      },
      listcha: [],
      member: this.$store.state.Member,
      Membermedicalhistory: {},
      BodytypeCha: [],
      MentalityresultCha: [],
    };
  },
  methods: {
    cz() {
      this.upform.scheme = {
        schemetittle: "",
        modelid: "",
        starttime: "",
        endtime: "",
        schemetarget: "",
        foods: [],
        sprots: [],
      };
    },

    load() {
      if (this.member.interposescheme) {
        this.upform.scheme = this.member.interposescheme;
      }
      if (this.member.interposefoods) {
        this.upform.scheme.foods = this.member.interposefoods;
      }
      if (this.member.interposesprots) {
        this.upform.scheme.sprots = this.member.interposesprots;
      }
      this.axios
        .get("/rear/Interposeclassify/MembermedicalhistoryCha", {
          params: { id: this.$store.state.Member.filenumber },
        })
        .then((res) => {
          this.Membermedicalhistory = res.data;
        })
        .catch((res) => {
          console.log("服务器出现问题，请联系管理员！");
        });
      this.axios
        .get("/rear/Interposeclassify/tijian", {
          params: { name: this.$store.state.Member.filenumber },
        })
        .then((res) => {
          this.listcha = res.data;
        })
        .catch((res) => {
          console.log("服务器出现问题，请联系管理员！");
        });
      this.axios
        .get("/rear/Interposeclassify/BodytypeCha", {
          params: { id: this.$store.state.Member.filenumber },
        })
        .then((res) => {
          this.BodytypeCha = res.data;
        })
        .catch((res) => {
          console.log("服务器出现问题，请联系管理员！");
        });
      this.axios
        .get("/rear/Interposeclassify/MentalityresultCha", {
          params: { id: this.$store.state.Member.filenumber },
        })
        .then((res) => {
          this.MentalityresultCha = res.data;
        })
        .catch((res) => {
          console.log("服务器出现问题，请联系管理员！");
        });
    },
    fh() {
      this.$router.push("/index/interposescheme?menusText=健康干预,干预方案");
    },
    jia(index, row) {
      this.upform.scheme = row;
    },
    changes(name) {
      this.axios
        .get("/rear/Scheme/pagecha", {
          params: {
            name: name.trim(),
          },
        })
        .then((res) => {
          this.Schemelist = res.data;
        })
        .catch((res) => {
          this.$message.error("服务器出现问题，请联系管理员！");
        });
    },

    // 饮食
    mpage() {
      this.axios
        .get("/rear/Scheme/mpage", {
          params: {
            num: this.meals.num,
            size: this.meals.size,
            name: this.meals.name.trim(),
          },
        })
        .then((res) => {
          this.meals.list = res.data.list;
          this.meals.total = res.data.total;
        })
        .catch((res) => {
          this.$message.error("服务器出现问题，请联系管理员！");
        });
    },
    mhandleSizeChange(val) {
      this.meals.size = val;
      this.mpage();
    },
    mhandleCurrentChange(val) {
      this.meals.size = val;
      this.mpage();
    },
    // 运动
    spage() {
      this.axios
        .get("/rear/Scheme/spage", {
          params: {
            num: this.sportsItemLibrary.num,
            size: this.sportsItemLibrary.size,
            name: this.sportsItemLibrary.name.trim(),
          },
        })
        .then((res) => {
          this.sportsItemLibrary.list = res.data.list;
          this.sportsItemLibrary.total = res.data.total;
        })
        .catch((res) => {
          this.$message.error("服务器出现问题，请联系管理员！");
        });
    },
    shandleSizeChange(val) {
      this.sportsItemLibrary.size = val;
      this.spage();
    },
    shandleCurrentChange(val) {
      this.sportsItemLibrary.size = val;
      this.spage();
    },

    loadUP(index, row) {
      this.dialogFormVisibleUpdate = true;
      this.upform.scheme = row;
    },
    upjia(index, row) {
      let food = { recommendfood: row.name, foodquantity: 1, eattimes: 1 };
      let bol = true;
      this.upform.scheme.foods.forEach((element) => {
        if (element.recommendfood == food.recommendfood) {
          bol = false;
        }
      });
      if (bol) {
        this.upform.scheme.foods.push(food);
      }
    },
    upjian(index, row) {
      this.upform.scheme.foods.splice(index, 1);
    },
    upjias(index, row) {
      let sprot = {
        sportname: row.name,
        sporttime: 1,
        sportcycle: "1 周",
      };
      let bol = true;
      this.upform.scheme.sprots.forEach((element) => {
        if (element.sportname == sprot.sportname) {
          bol = false;
        }
      });
      if (bol) {
        this.upform.scheme.sprots.push(sprot);
      }
    },
    upjians(index, row) {
      this.upform.scheme.sprots.splice(index, 1);
    },
    fjiaUP(index, row) {
      if (row.foodquantity == 15) {
        return;
      }
      this.upform.scheme.foods[index].foodquantity = row.foodquantity + 1;
    },
    fjianUP(index, row) {
      if (row.foodquantity == 1) {
        return;
      }
      this.upform.scheme.foods[index].foodquantity = row.foodquantity - 1;
    },
    cjiaUP(index, row) {
      if (row.eattimes == 5) {
        return;
      }
      this.upform.scheme.foods[index].eattimes = row.eattimes + 1;
    },
    cjianUP(index, row) {
      if (row.eattimes == 1) {
        return;
      }
      this.upform.scheme.foods[index].eattimes = row.eattimes - 1;
    },

    add() {
      if (this.upform.scheme.modelid == "") {
        this.$message({
          message: "请选择模版 ！",
          type: "warning",
        });
        return;
      }
      let bol = true;
      this.upform.scheme.sprots.forEach((element) => {
        if (isNaN(element.sporttime)) {
          bol = false;
        }
      });
      if (!bol) {
        this.$message({
          message: "运动干预的运动的时长'类型异常' ！",
          type: "warning",
        });
        return;
      }

      const loading = this.$loading({
        lock: true,
        text: "正在拼命提交中...",
        spinner: "el-icon-loading",
        background: "rgba(0, 0, 0, 0.7)",
      });
      this.member.interposescheme = this.upform.scheme;
      this.member.interposefoods = this.upform.scheme.foods;
      this.member.interposesprots = this.upform.scheme.sprots;

      this.axios
        .post("/rear/Interposescheme/add", this.member)
        .then((res) => {
          if (res.data) {
            this.$message({
              message: "提交成功！",
              type: "success",
            });
          }
          this.dialogFormVisibleUpdate = false;
          loading.close();
          this.$router.push(
            "/index/interposescheme?menusText=健康干预,干预方案"
          );
        })
        .catch((res) => {
          this.$message.error("服务器出现问题，请联系管理员！");
          this.dialogFormVisibleUpdate = false;
          loading.close();
        });
    },
  },
  created() {
    this.load();
  },
};
</script>

<style scoped>
#d {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
  width: 100%;
  height: 800px;
}
</style>